.class public Lcom/htc/android/footprints/utils/PreloadDataRunnable;
.super Ljava/lang/Object;
.source "PreloadDataRunnable.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;
    }
.end annotation


# static fields
.field private static final CACHED_H:I = 0x32

.field private static final CACHED_W:I = 0x32

.field private static final KEY:Ljava/lang/String; = "ListModeActivity"

.field public static final TAG:Ljava/lang/String; = "PreloadDataRunnable"

.field private static final sortBy:Ljava/lang/String; = "create_time desc"


# instance fields
.field private footprints:[Lcom/htc/android/footprints/vo/Footprint;

.field private mDbManager:Lcom/htc/android/footprints/provider/FootprintManager;

.field private mImageManager:Lcom/htc/android/footprints/utils/camera/FootprintImageManager;

.field private mIsPreloading:Z

.field private mPreloadListener:Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;


# direct methods
.method public constructor <init>(Landroid/content/Context;[Lcom/htc/android/footprints/vo/Footprint;)V
    .locals 2
    .parameter "context"
    .parameter "data"

    .prologue
    const/4 v1, 0x0

    .line 38
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 33
    iput-object v1, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    .line 35
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mIsPreloading:Z

    .line 36
    iput-object v1, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mPreloadListener:Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;

    .line 39
    invoke-static {p1}, Lcom/htc/android/footprints/provider/FootprintManager;->getInstance(Landroid/content/Context;)Lcom/htc/android/footprints/provider/FootprintManager;

    move-result-object v0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mDbManager:Lcom/htc/android/footprints/provider/FootprintManager;

    .line 40
    invoke-static {}, Lcom/htc/android/footprints/utils/camera/FootprintImageManager;->getInstance()Lcom/htc/android/footprints/utils/camera/FootprintImageManager;

    move-result-object v0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mImageManager:Lcom/htc/android/footprints/utils/camera/FootprintImageManager;

    .line 41
    if-eqz p2, :cond_0

    array-length v0, p2

    if-lez v0, :cond_0

    iput-object p2, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    .line 42
    :cond_0
    return-void
.end method

.method private preloadPhoto(Ljava/lang/String;)V
    .locals 3
    .parameter "filepath"

    .prologue
    const/16 v2, 0x32

    .line 78
    if-eqz p1, :cond_0

    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v0

    if-nez v0, :cond_1

    .line 82
    :cond_0
    :goto_0
    return-void

    .line 79
    :cond_1
    iget-object v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mImageManager:Lcom/htc/android/footprints/utils/camera/FootprintImageManager;

    const-string v1, "ListModeActivity"

    invoke-virtual {v0, v1, v2, v2, p1}, Lcom/htc/android/footprints/utils/camera/FootprintImageManager;->cachedScaledFastImage(Ljava/lang/String;IILjava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    goto :goto_0
.end method


# virtual methods
.method public declared-synchronized getPreloadingStatus()Z
    .locals 1

    .prologue
    .line 93
    monitor-enter p0

    :try_start_0
    iget-boolean v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mIsPreloading:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit p0

    return v0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public run()V
    .locals 12

    .prologue
    const/4 v10, 0x0

    const-string v11, "PreloadDataRunnable"

    .line 45
    invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J

    move-result-wide v6

    .line 46
    .local v6, start1:J
    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    if-nez v8, :cond_4

    .line 47
    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mDbManager:Lcom/htc/android/footprints/provider/FootprintManager;

    const-string v9, "create_time desc"

    invoke-virtual {v8, v10, v9}, Lcom/htc/android/footprints/provider/FootprintManager;->findFootprintCursorByCategory(Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 48
    .local v1, cursor:Landroid/database/Cursor;
    if-eqz v1, :cond_0

    invoke-interface {v1}, Landroid/database/Cursor;->getCount()I

    move-result v8

    if-lez v8, :cond_0

    .line 49
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    move-result v8

    if-eqz v8, :cond_0

    iget-boolean v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mIsPreloading:Z

    if-eqz v8, :cond_0

    .line 51
    const-wide/16 v8, 0xa

    :try_start_0
    invoke-static {v8, v9}, Ljava/lang/Thread;->sleep(J)V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 55
    :goto_1
    const-string v8, "pic_path"

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v8

    invoke-interface {v1, v8}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v8

    invoke-direct {p0, v8}, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->preloadPhoto(Ljava/lang/String;)V

    goto :goto_0

    .line 52
    :catch_0
    move-exception v2

    .line 53
    .local v2, e:Ljava/lang/InterruptedException;
    invoke-virtual {v2}, Ljava/lang/InterruptedException;->printStackTrace()V

    goto :goto_1

    .line 58
    .end local v2           #e:Ljava/lang/InterruptedException;
    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    .line 68
    .end local v1           #cursor:Landroid/database/Cursor;
    :cond_1
    iput-object v10, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mDbManager:Lcom/htc/android/footprints/provider/FootprintManager;

    .line 69
    iput-object v10, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mImageManager:Lcom/htc/android/footprints/utils/camera/FootprintImageManager;

    .line 70
    iput-object v10, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    .line 71
    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mPreloadListener:Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;

    if-eqz v8, :cond_2

    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mPreloadListener:Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;

    const/4 v9, 0x1

    invoke-interface {v8, v9}, Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;->preloadCompete(Z)V

    .line 72
    :cond_2
    const-string v8, "PreloadDataRunnable"

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "end preloading :"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J

    move-result-wide v9

    sub-long/2addr v9, v6

    invoke-virtual {v8, v9, v10}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v11, v8}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 73
    const-string v8, "PreloadDataRunnable"

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "end preloading externalByte:"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-static {}, Ldalvik/system/VMRuntime;->getRuntime()Ldalvik/system/VMRuntime;

    move-result-object v9

    invoke-virtual {v9}, Ldalvik/system/VMRuntime;->getExternalBytesAllocated()J

    move-result-wide v9

    invoke-virtual {v8, v9, v10}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v11, v8}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 75
    :cond_3
    return-void

    .line 60
    :cond_4
    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    if-eqz v8, :cond_3

    iget-object v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    array-length v8, v8

    if-eqz v8, :cond_3

    .line 61
    iget-object v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->footprints:[Lcom/htc/android/footprints/vo/Footprint;

    .local v0, arr$:[Lcom/htc/android/footprints/vo/Footprint;
    array-length v5, v0

    .local v5, len$:I
    const/4 v4, 0x0

    .local v4, i$:I
    :goto_2
    if-ge v4, v5, :cond_1

    aget-object v3, v0, v4

    .line 62
    .local v3, f:Lcom/htc/android/footprints/vo/Footprint;
    iget-boolean v8, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mIsPreloading:Z

    if-eqz v8, :cond_5

    .line 63
    iget-object v8, v3, Lcom/htc/android/footprints/vo/Footprint;->mPicPath:Ljava/lang/String;

    invoke-direct {p0, v8}, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->preloadPhoto(Ljava/lang/String;)V

    .line 61
    :cond_5
    add-int/lit8 v4, v4, 0x1

    goto :goto_2
.end method

.method public setPreloadListener(Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;)V
    .locals 0
    .parameter "pl"

    .prologue
    .line 85
    if-eqz p1, :cond_0

    iput-object p1, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mPreloadListener:Lcom/htc/android/footprints/utils/PreloadDataRunnable$PreloadListener;

    .line 86
    :cond_0
    return-void
.end method

.method public declared-synchronized stopPreloading()V
    .locals 1

    .prologue
    .line 89
    monitor-enter p0

    const/4 v0, 0x0

    :try_start_0
    iput-boolean v0, p0, Lcom/htc/android/footprints/utils/PreloadDataRunnable;->mIsPreloading:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 90
    monitor-exit p0

    return-void

    .line 89
    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method
